<template>
  <div class="test-page">
    <h1>测试页面</h1>
    <p>如果你能看到这个页面，说明前端服务正常运行！</p>
    <el-button type="primary" @click="testApi">测试API连接</el-button>
    <div v-if="apiResult">
      <h3>API测试结果：</h3>
      <pre>{{ apiResult }}</pre>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const apiResult = ref('')

const testApi = async () => {
  try {
    const response = await fetch('/api/health')
    const data = await response.json()
    apiResult.value = JSON.stringify(data, null, 2)
  } catch (error) {
    apiResult.value = `错误: ${error}`
  }
}
</script>

<style scoped>
.test-page {
  padding: 2rem;
  text-align: center;
}

pre {
  background: #f5f5f5;
  padding: 1rem;
  border-radius: 4px;
  text-align: left;
  max-width: 500px;
  margin: 0 auto;
}
</style>
